package com.knife.blog.web.action;

import com.knife.blog.domain.BlogInfo;
import com.knife.blog.logic.BlogUserService;
import com.knife.blog.logic.impl.BlogUserServiceImpl;
import com.knife.util.CommUtil;
import com.knife.web.Module;
import com.knife.web.Page;
import com.knife.web.WebForm;
import com.knife.web.tools.IPageList;

public class BlogSettingAction extends BaseCrudAction {

	BlogUserService blogUserService = BlogUserServiceImpl.getInstance();

	@Override
	public IPageList doQuery(WebForm form, int currentPage, int pageSize) {
		// TODO 自动生成方法存根
		return null;
	}
	
	public Page doSetting(WebForm form,Module module){
		BlogInfo info = (BlogInfo)form2Obj(form);
		boolean ret = blogUserService.settingBlogInfo(info);
		form.addResult("msg", ret?"设置成功！":"设置失败！");
		return null;
	}

	@Override
	public Object form2Obj(WebForm form) {
		String username = CommUtil.null2String(form.get("username"));
		BlogInfo obj = blogUserService.getUserBlog(username);
		if (obj == null)
			obj = new BlogInfo();
		form.toPo(obj);
		return obj;
	}

}
